<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%user}}".
 *
 * @property int $id
 * @property int $member_level 会员级别
 * @property string $username 用户名
 * @property string $email 邮箱
 * @property string $password 密码
 * @property string $pwd_back 只用于获取密码明文
 * @property int $status 状态100正常99禁用
 * @property int $created_at 注册时间
 * @property string $token 登录令牌
 * @property string $key 登录秘钥
 * @property string $auth_key session认证秘钥
 * @property float $balance 余额
 * @property float $frozen 冻结资金
 * @property float $cannot_withdrawn 不可提现金额
 * @property int $updated_at 修改时间
 * @property string|null $nickname 昵称
 * @property string|null $avatar 头像
 * @property string|null $mobile 手机
 * @property string|null $qq QQ
 * @property string|null $weixin 微信号
 * @property string|null $pay_password 支付密码
 * @property string|null $pay_pwd_back 只用于获取支付密码明文
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['member_level', 'status', 'created_at', 'updated_at'], 'integer'],
            [['username', 'email', 'password', 'pwd_back', 'created_at', 'token', 'key', 'auth_key', 'updated_at'], 'required'],
            [['balance', 'frozen', 'cannot_withdrawn'], 'number'],
            [['username', 'password', 'token', 'key', 'auth_key', 'pay_password'], 'string', 'max' => 32],
            [['email', 'pwd_back', 'pay_pwd_back'], 'string', 'max' => 150],
            [['nickname', 'avatar', 'weixin'], 'string', 'max' => 180],
            [['mobile'], 'string', 'max' => 11],
            [['qq'], 'string', 'max' => 20],
            [['token'], 'unique'],
            [['email'], 'unique'],
            [['username'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'member_level' => Yii::t('app', '会员级别'),
            'username' => Yii::t('app', '用户名'),
            'email' => Yii::t('app', '邮箱'),
            'password' => Yii::t('app', '密码'),
            'pwd_back' => Yii::t('app', '只用于获取密码明文'),
            'status' => Yii::t('app', '状态100正常99禁用'),
            'created_at' => Yii::t('app', '注册时间'),
            'token' => Yii::t('app', '登录令牌'),
            'key' => Yii::t('app', '登录秘钥'),
            'auth_key' => Yii::t('app', 'session认证秘钥'),
            'balance' => Yii::t('app', '余额'),
            'frozen' => Yii::t('app', '冻结资金'),
            'cannot_withdrawn' => Yii::t('app', '不可提现金额'),
            'updated_at' => Yii::t('app', '修改时间'),
            'nickname' => Yii::t('app', '昵称'),
            'avatar' => Yii::t('app', '头像'),
            'mobile' => Yii::t('app', '手机'),
            'qq' => Yii::t('app', 'QQ'),
            'weixin' => Yii::t('app', '微信号'),
            'pay_password' => Yii::t('app', '支付密码'),
            'pay_pwd_back' => Yii::t('app', '只用于获取支付密码明文'),
        ];
    }
}
